import { sequelize } from '../../../db';
import { DataTypes, Model } from 'sequelize';
class Customize extends Model { }

Customize.init({
    phone: DataTypes.STRING,
    UserId: DataTypes.INTEGER,
    toUserId: DataTypes.INTEGER,
    community: DataTypes.STRING,
    CommunityId: DataTypes.INTEGER,
    state: {
        type: DataTypes.INTEGER,
        defaultValue: 1
    },
    state_name: {
        type: DataTypes.VIRTUAL,
        get() {
            const dis = ['已取消', '未确认', '沟通中', '已确认', '已完成', '隐藏']
            return dis[this.dataValues.state]
        },
        set(value) {
            throw new Error('不要尝试设置 `create` 的值!');
        }
    }
}, {
    sequelize
});

export default Customize